harroway_bay12fandomcom_ru-20200213-history
NT Script
The NT Scripting Language(NT Script, or NTSL) is a new piece of technology being pushed by NT Tech Department to standardize programming and communication of all Nanotrasen-grade electronic devices. Its syntax is a mixture of PHP, C++, and JavaScript. Most implementations of NT Script are not object-oriented and do not allow the definition of classes, instead, rely on ROBUST™ memory management system to store entities in a dynamic data tree. NT Script does allow the in-line definition of functions, however. It is important to note that NT Scripting should not be treated as BYOND coding. NT Scripting handles some things differently than BYOND does. Syntax Guide NT Script follows a simple-to-use syntax designed for users of all levels of programming expertise. Whitespace is ignored, semicolon break points are required, and curly brackets are required. Variables Variables are used to temporarily store any form of data that can be accessed somewhere else in the code. For simplicity, we'll ignore the fact that you can only use variables in children scope. Here is how you create a variable: myVariable = 5; You can alternatively assign the same variable a text value, or a string. myVariable = "Hello world!"; Functions Functions can be used and defined dynamically. There are different pre-defined functions for each NTSL implementation, however the basic ones will remain the same. Here is how you use a function: myVariable = getNumber(); In this example, myVariable is assigned whatever value getNumber() returns. Each function returns a value, even if a value return is explicitly not defined. Here are some more examples of how to use functions: print(myVariable); print("Hello world!"); print("Griffing assistants in T-minus " + myVariable + " seconds."); You can also define your own functions, using the def keyword. def getNumber() { return 5; } Code Blocks Blocks of code are called when a specific piece of code signals that it is a representation of a block of code. Variables defined in one code block cannot be applied or changed in other nonrelated code blocks; this is known as scope. For example: myGlobalVariable = getNumber(); while(myGlobalVariable != 0) { myLocalVariable = 0; myGlobalVariable = myLocalVariable; } myLocalVariable = 50; // this is invalid; myLocalVariable does not exist in this scope Once the interpreter reads the closing bracket, it destroys all variable definitions within the scope, therefore you cannot use any of the variables that existed in that particular block of code. Conditionals The while() loop in the previous example is considered a conditional because it only continues executing when the condition between the parentheses is true. The != is known as a relational operator which returns true to the interpreter if myGlobalVariable does not equal 0. It can be read as "while myGlobalVariable does not equal 0, execute the following block of code". Here is a list of all relational operators: : Equals != : Does not equal <''' : Less than '''> : Greater than <= : Less than or equal to >= : Greater than or equal to Relational operators can be used in if() statements, which are used the following way: if(myVariableNumber 50) { // code block } else { // the relational operator was not met // code block } NT Deluxe Namespaces Nanotrasen will constantly add new universal functions and features to NTSL, here are a few of them: Vector Namespace Vectors are resizeable data containers for storing any form of entities inside. They are very useful for serving as lists; their members can be instantly accessed provided you have an appropriate position. vector() vector(entry1, entry2, ...) Returns a vector with a given number of entities. You can add an infinite number of entries, or no entries at all. at() at(vector, position, value) The NTSL-equivalent of arrayindex. A NTSL vector starts at index 1. As the language develops, this will most likely be offloaded to the [] operator. copy() copy(vector, start, end) Returns a new vector with only the contents of the specified vector at the start position and end position. push_back() push_back(vector, entry1, entry2, ...) Adds specified entries to the specified vector. Note: the ''+=''operator overloads this function, and can be used as so: vector += myName; remove() remove(vector, entry1, entry2, ...) Removes specified entries from the specified vector. cut() cut(vector, start, end) Cuts out entries from start to end in the specified vector. swap() swap(vector, index1, index2) Swaps the entities at index1 and index2 in the specified vector. insert() insert(vector, index, entry) Inserts an entry into the specified position. Miscellaneous Definitions pick() pick(entry1, entry2, entry3, ...) Returns a randomly-selected entry from the parameters. Note: vector parameters will add their entries into the "raffle". The function will never return a vector. find() find(container, element) Searches a vector or string for this element or substring. Returns nonzero if found. prob() prob(chance) Returns nonzero is the probability succeeded. Returns zero if the probability failed. length() length(container) Finds the length of a string or vector. substr() substr(string, start, end) Returns a string/text copied from the specified string, from start to end. Prefab Variables PI = 3.141592653; E''' = 2.718281828; '''SQURT2 = 1.414213562; FALSE = 0; // true/false are just Boolean shortcuts to 0 and 1 TRUE = 1; NORTH/SOUTH/EAST/WEST = direction; // can be any cardinal direction (UNDER CONSTRUCTION) Traffic Control Systems Implementation The Telecommunications system is directly tied to the TCS scripting implementation. It comes with the following functions and features. Realtime signal modification If the code is set to execute automatically, signals will first execute stored server code. Signal information is stored in the following variables: $source // the source of the signal $content // the content of the signal $freq // the frequency of the signal $pass // determines if the signal will be broadcasted $job // the job (only for radio messages) of the orator Functions TCS also comes with the following functions (parameters may be ignored for automatic assignment): broadcast() broadcast(message, frequency, source, job) Sends a radio signal to neighboring subspace broadcasters to broadcast with the following parameters. message: The radio message frequency: The frequency to broadcast to source: The name of the broadcaster. If the source name is not in a server-side voice databank (voice analysis is performed every time a person speaks over a channel) the name will appear in UPPERCASE and Italicized to indicate a synthesized voice job job: The job of the orator. Examples: broadcast("Hello world!"); defaults: frequency: 1459 source: the server name job: None broadcast("HELP GRIEFF", 1459, "Burer", "Security Officer"); mem() mem(address, value) Either returns a value if value is not specified, or sets the value of the memory address address: The memory address to search or apply to value: The value to apply to the address. Can be any form of data Examples: mem($source + "'s Mom"); mem($source + "'s Mom", "Lindsay Donk"); Category:Guides